if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[v_tb_posclosemoney]') and OBJECTPROPERTY(id, N'IsView') = 1)
drop view [dbo].[v_tb_posclosemoney]
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO


create  view v_tb_posclosemoney
as
SELECT     m.bid, m.bcode, m.bstate, m.bdate, m.voucherid, m.filid, m.remark, d.balanceid, d.amount, d.accountid
FROM         dbo.tb_posclosemoney AS d INNER JOIN
                      dbo.tb_posclose AS m ON m.bid = d.bid INNER JOIN
                      dbo.td_balance AS l ON l.balanceid = d.balanceid AND l.pos = 1
WHERE     (1 = 1) AND (d.accountid IS NOT NULL)